#ifndef __SSD2828_H__
#define __SSD2828_H__

/* PORT */
#include "main.h"

//#include "ST7796S__PH035NA_01B.h"

typedef uint8_t U8;
typedef uint16_t U16;
typedef uint32_t U32;

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;


#define SPI_CMD 0
#define SPI_DAT 1

extern void spi_init(void);
extern void spi_write(uint8_t cod, uint8_t data);

#define delay_ms(x) HAL_Delay(x)

#define CLR_SDA() HAL_GPIO_WritePin(LCD_MOSI_GPIO_Port, LCD_MOSI_Pin, GPIO_PIN_RESET)
#define SET_SDA() HAL_GPIO_WritePin(LCD_MOSI_GPIO_Port, LCD_MOSI_Pin, GPIO_PIN_SET)

#define CLR_CLK() HAL_GPIO_WritePin(LCD_SCK_GPIO_Port, LCD_SCK_Pin, GPIO_PIN_RESET)
#define SET_CLK() HAL_GPIO_WritePin(LCD_SCK_GPIO_Port, LCD_SCK_Pin, GPIO_PIN_SET)

#define CLR_CS() HAL_GPIO_WritePin(LCD_CS_GPIO_Port, LCD_CS_Pin, GPIO_PIN_RESET)
#define SET_CS() HAL_GPIO_WritePin(LCD_CS_GPIO_Port, LCD_CS_Pin, GPIO_PIN_SET)

#define CLR_RST() HAL_GPIO_WritePin(LCD_RST_GPIO_Port, LCD_RST_Pin, GPIO_PIN_RESET)
#define SET_RST() HAL_GPIO_WritePin(LCD_RST_GPIO_Port, LCD_RST_Pin, GPIO_PIN_SET)

#define getMISO() HAL_GPIO_ReadPin(LCD_MISO_GPIO_Port, LCD_MISO_Pin)


/* private defines */
#define GEN 0
#define DCS 1

/* DISPLAY INFO */
/*#define LCD_XSIZE 1200
#define LCD_YSIZE 1920
#define LCD_BPP 16 //16  24位选择
#define FRAME_RATE 30
#define LCD_ROTATE 0
#define HBPD 80 //48
#define HFPD 80 //16
#define HSPW 30 //8
#define VBPD 9  //3
#define VFPD 4  //5
#define VSPW 4  //8*/

void W_C(u8 CMD);
void W_D(u8 DAT);
void GP_COMMAD_PA(u16 a);
void sendFormat(u8 format, u16 len);
void ssd2828_readID(void);
void readMipi(U8 type, U8 lpclk, U8 returnLen, U8 mipiSlaveRegAddr, U16 *returnData);
void Init_SSD2828(void (*lcd_init)(void));
U16 SPI_READ_REG(U8 reg);


void ssd2828_hwreset(void);
void ssd2828_writeReg(uint8_t addr, uint8_t data15_8, uint8_t data7_0);
uint16_t ssd2828_readReg(uint8_t reg);


#endif //__SSD2828_H__
/* END OF FILE */
